package com.knife.tools;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

import com.knife.blog.logic.CurrentUser;
import com.knife.web.tools.IActiveUser;

public class HtmlFilter implements Filter {

	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain filterchain) throws java.io.IOException,
			javax.servlet.ServletException {
		HttpServletResponse httpResponse = (HttpServletResponse) response;
		// TODO Auto-generated method stub
		IActiveUser user = CurrentUser.getActiveUser();
		if (user == null) {
			// 请先登录
			httpResponse.sendRedirect("/blogLogin.do");
			// return module.findPage("login");
		} else {
			filterchain.doFilter(request, response);
		}
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
		// TODO Auto-generated method stub

	}
}